<?php
include "includes/sesiones.php";
include "includes/comunes.php";
//busco el credito
$sql="select * from creditos where id=".$_GET['cre_id'];
$rescre= $consultar=  cons_ins($sql);
$regcre=mysql_fetch_array($rescre);

//busco el recibo actual
 $sqlPago="select * from recibos where credito=".trim($_GET['cre_id'])." and cuota=".trim($_GET['cuota'])." order by Id desc";
  $respag=  cons_ins($sqlPago);
  $regpag=mysql_fetch_array($respag);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Impresion de Comprobante</title>
<style type="text/css">
<!--
.Estilo1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.Estilo2 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<table width="500" height="425" border="0" align="center">
  <tr style="border-top: 1px solid #666666">
    <td colspan="2" rowspan="3"><div align="center" class="Estilo1" >COMERCIALIZADORA MASS </div></td>
    <td height="50" colspan="2"><span class="Estilo2">Fec. Impr. <br><?php echo date("d/m/Y H:i:s")?> </span></td>
  </tr>
    <tr>
        <td height="26" colspan="2"><span class="Estilo2">Pto. Vta.: <?php echo obtener_nombre_sucursal($regcre['sucursal'])?></span></td>
  </tr>
  <tr>
    <td height="26" colspan="2"><span class="Estilo2">Usuario: <?php echo $_SESSION['Usuario']?></span></td>
  </tr>
  <tr>
    <td height="26" colspan="2"><span class="Estilo2">Recibo N&ordm;: <?php echo $regpag['Id']?></span> </td>
  </tr>
  <tr style="border-top: 1px solid #666666">
    <td height="57" colspan="4" style="border-top: 1px solid #666666"><span class="Estilo2">DNI: <?php echo $regcre['cliente']?><br/>
           Cliente:<?php echo obtener_cliente($regcre['cliente'])?><br/>
    </td>
  </tr>
  <tr style="border-top: 1px solid #666666">
    <td height="65" colspan="4" style="border-top: 1px solid #666666"><span class="Estilo2">Credito: <?php echo $regcre['id']?><br/>
    Monto Total Solicitado: $ <?php echo $regcre['monto']?><br/>
    Fecha Otorgamiento: <?php echo format_fec($regcre['fecha'],"/")?></br>
        Monto Cuota: $ <?php echo round(obtener_monto_cuotas($_GET['cre_id'], $_GET['cuota']))?><br/></span></td>
  </tr>
  <tr bgcolor="#666666">
    <td height="23" colspan="4" style="border-top: 1px solid #666666; border-bottom:1px solid #666666"><span class="Estilo2"> HISTORICO DE PAGOS REALIZADOS </span> </td>
  </tr>
  <tr>
   <?php
  $sqlRec="select * from recibos where credito=".trim($_GET['cre_id'])." and cuota=".trim($_GET['cuota'])." order by Id desc";
  $resrec=  cons_ins($sqlRec);
  
  while ($regrec=mysql_fetch_array($resrec)):
  ?>
  <tr>
      <td align="center"><span class="Estilo2">Recibo N&ordm; : <?php echo $regrec['Id']?></span></td>
      <td align="center"><span class="Estilo2">Fecha: <?php echo format_fec($regrec['fecha'],"/")?></span></td>
    <td align="center"><span class="Estilo2">Monto: $<?php echo round($regrec['pagado']+$regrec['punitorios'])?></span></td>

  </tr>
  <?php
 
  endwhile
  ?>
  </tr>
  <tr bgcolor="#666666">
    <td height="33" colspan="4" style="border-top: 1px solid #666666; border-bottom:1px solid #666666"><span class="Estilo2">DETALLE DE PAGO</span> </td>
  </tr>
  <tr>
    <td colspan="3"> <span class="Estilo2">Pago de cuota Pura  Nro <?php echo $regpag['cuota']?> </span></td>
    <td><span class="Estilo2">$ <?php echo round($regpag['pagado'])?></span></td>
  </tr>
  <tr>
    <td colspan="3"><span class="Estilo2">Punitorios </span></td>
    <td><span class="Estilo2">$ <?php echo round($regpag['punitorios'])?></span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr style="border-top: 1px solid #666666">
    <td width="124" bgcolor="#666666" style="border-top: 1px solid #666666"><span class="Estilo2">Total Abonado </span></td>
    <td width="135" style="border-top: 1px solid #666666">&nbsp;<span class="Estilo2">$ <?php echo round($regpag['pagado']+$regpag['punitorios'])?></span></td>
    <td width="112" bgcolor="#666666" style="border-top: 1px solid #666666"><span class="Estilo2">Saldo Cuota</span> </td>
    <td width="111" style="border-top: 1px solid #666666">&nbsp;<span class="Estilo2">$ <?php echo round(obtener_saldo($_GET['cre_id'],$_GET['cuota']))?></span></td>
  </tr>
  <tr>
      <td colspan="4" style="border-top: 1px solid #666666; border-bottom:1px solid #666666">
          <br></br><div align="center"><a onclick="window.print();"  style="width:200px; border-left: 300px;">
                <img src="images/imprimir.png" border="0" width="25px"/></a></div></td>
    
  </tr>
</table>
</body>
</html>
